<template>
  <div style="position: relative">
    <div class="content">
      <div class="info" v-if="this.$route.query.type == 1 ? true : false">
        <div class="title">基本信息</div>
        <div class="list">
          <div class="item">
            <div class="tit">商户订单号</div>
            <div class="desc">{{ this.info.payformNo }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            >
              <i
                class="el-icon-document-copy"
                @click="copyAppId(info.payformNo)"
              ></i>
            </div>
          </div>
          <div class="item">
            <div class="tit">云尘付流水号</div>
            <div class="desc">{{ this.info.innerPayformNo }}</div>
            <div
              style="
                margin-left: 32px;
                color: #03bfc6;
                line-height: 40px;
                cursor: pointer;
              "
            >
              <i
                class="el-icon-document-copy"
                @click="copyAppId(info.innerPayformNo)"
              ></i>
            </div>
          </div>
          <div class="item">
            <div class="tit">支付渠道</div>
            <div class="desc">{{ this.info.channelPayFormTypeName }}</div>
          </div>
          <div class="item">
            <div class="tit">订单金额/元</div>
            <div class="desc">{{ this.info.fmtOriginalAmount }}</div>
          </div>
        </div>
      </div>
      <div class="info" v-else>
        <div class="title">基本信息</div>
        <div class="list">
          <div class="item">
            <div class="tit">创建时间</div>
            <div class="desc">
              {{ info.gmtCreated ? info.gmtCreated : "-" }}
            </div>
          </div>
          <div class="item">
            <div class="tit">退款批次号</div>
            <div class="desc">{{ info.batchNo ? info.batchNo : "-" }}</div>
          </div>
          <div class="item">
            <div class="tit">退款总金额/元</div>
            <div class="desc">
              {{ info.fmtTotalRefundAmount ? info.fmtTotalRefundAmount : "-" }}
            </div>
          </div>
          <div class="item">
            <div class="tit">退款总笔数</div>
            <div class="desc">
              {{ info.orderCount ? info.orderCount : "-" }}
            </div>
          </div>
          <div class="item">
            <div class="tit">退款总手续费/元</div>
            <div class="desc">
              {{
                info.fmtTotalRefundFeeAmount
                  ? info.fmtTotalRefundFeeAmount
                  : "-"
              }}
            </div>
          </div>
          <div class="item">
            <div class="tit">退款发起人</div>
            <div class="desc">
              {{
                info.payformRefundResList
                  ? (info.payformRefundResList[0].createUserName?info.payformRefundResList[0].createUserName:"-")
                  : "-"
              }}
            </div>
          </div>
          <div class="item">
            <div class="tit">退款理由</div>
            <div class="desc">
              {{
                info.reason
                  ? info.reason
                  : "-"
              }}
            </div>
          </div>
          <div class="item">
            <div class="tit">退款状态</div>
            <div class="desc">
              {{
                info.refundStatus ? setRefundStatus(info.refundStatus).str : "-"
              }}
            </div>
          </div>
        </div>
      </div>

      <div class="info" v-if="this.$route.query.type == 1 ? true : false">
        <div class="title">退款信息</div>
        <div class="list">
          <div class="item">
            <div class="tit">创建时间</div>
            <div class="desc">{{ this.info.gmtCreated ?this.info.gmtCreated:'-'}}</div>
          </div>
          <div class="item">
            <div class="tit">退款订单号</div>
            <div class="desc">{{ this.info.refundNo? this.info.refundNo:'-'}}</div>
          </div>
          <div class="item">
            <div class="tit">退款流水号</div>
            <div class="desc">{{ this.info.innerRefundNo ? this.info.innerRefundNo:'-'}}</div>
          </div>
          <div class="item">
            <div class="tit">退款金额/元</div>
            <div class="desc">{{ this.info.fmtRefundAmount ?this.info.fmtRefundAmount:'-'}}</div>
          </div>
          <div class="item">
            <div class="tit">退款手续费/元</div>
            <div class="desc">{{ this.info.fmtRefundFeeAmount ?this.info.fmtRefundFeeAmount:'-'}}</div>
          </div>
          <div class="item">
            <div class="tit">退款发起人</div>
            <div class="desc">{{ this.info.createUserName? this.info.createUserName:'-'}}</div>
          </div>
          <div class="item">
            <div class="tit">退款理由</div>
            <div class="desc">{{ this.info.reason ? this.info.reason:'-'}}</div>
          </div>
          <div class="item">
            <div class="tit">退款状态</div>
            <div class="desc">{{ this.info.refundStatusName ? this.info.refundStatusName:'-'}}</div>
          </div>
          <div class="item" v-if="this.info.refundStatus =='fail_refund'">
            <div class="tit">失败原因</div>
            <div class="desc">{{ this.info.errorInfo ? this.info.errorInfo:'-'}}</div>
          </div>
          <div class="item">
            <div class="tit">退款时间</div>
            <div class="desc">{{ this.info.refundTime ? this.info.refundTime:'-'}}</div>
          </div>
        </div>
      </div>
      <div class="info" v-else style="min-width: 935px">
        <div class="title">{{ merchantInfo.title }}</div>
        <div class="list" style="position: relative">
          <div
            class="item"
            v-for="(item, index) of merchantInfo.infoList"
            :key="index"
          >
            <div class="tit" style="margin-left: -43px">{{ item.title }}</div>
            <div class="desc">{{ item.data }}</div>
          </div>
          <!-- <div style="position: absolute;right: 0;top: 10px;color: #03BFC6;cursor: pointer;" @click="openShow=!openShow">{{openShow?'收起':'展开'}}</div> -->
          <div v-if="openShow" style="margin-top: 40px">
            <tr class="openBox">
              <td>原订单号</td>
              <td>退款时间</td>
              <td>退款金额/元</td>
              <td>退款手续费/元</td>
              <td>退款状态</td>
            </tr>
            <div
              class="openBox1"
              v-for="(o, oIndex) in info.payformRefundResList"
              :key="oIndex"
            >
              <td :title="o.payformNo ? o.payformNo : ''">
                {{ o.payformNo ? o.payformNo : "-" }}
              </td>
              <td :title="o.refundTime ? o.refundTime : ''">{{ o.refundTime ? o.refundTime : "-" }}</td>
              <td>
                {{ o.fmtRefundAmount ? o.fmtRefundAmount : "-" }}
              </td>
              <td>
                {{ o.fmtRefundFeeAmount ? o.fmtRefundFeeAmount : "-" }}
              </td>
              <td>
                {{ o.refundStatusName ? o.refundStatusName : "-" }}
              </td>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="back" @click="backFn">
      <i class="el-icon-close"></i>
    </div>
    <div class="left">
      <el-breadcrumb separator=">" style="margin-bottom: 20px">
        <el-breadcrumb-item v-for="item of breadList" :key="item">{{
          item
        }}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
  </div>
</template>

<script>
export default {
  name: "refundToolDetail",
  components: {},
  data() {
    return {
      info: {},
      openShow: true,
      breadList: [],
      basicInfo: {
        title: "基本信息",
        infoList: [
          {
            title: "订单号",
            data: "87930235949282",
            copy: "true",
          },
          {
            title: "支付渠道",
            data: "支付宝",
          },
          {
            title: "订单金额/元",
            data: "150.00",
          },
        ],
      },
      basicInfo1: {
        title: "基本信息",
        infoList: [
          {
            title: "创建时间",
            data: "2023-01-03 14:00",
          },
          {
            title: "退款批次号",
            data: "YC739008937420535",
            copy: "true",
          },
          {
            title: "退款总金额/元",
            data: "150.00",
          },
          {
            title: "退款总笔数",
            data: "3",
          },
          {
            title: "退款手续费/元",
            data: "0.00",
          },
        ],
      },
      payInfo: {
        title: "退款信息",
        infoList: [
          {
            title: "创建时间",
            data: "2023-01-23 14:00",
          },
          {
            title: "退款流水号",
            data: "879634090233540",
          },
          {
            title: "退款金额/元",
            data: "¥300.00",
          },
          {
            title: "退款手续费/元",
            data: "¥3.00",
          },
          {
            title: "退款状态",
            data: "成功",
          },
        ],
      },
      merchantInfo: {
        title: "退款信息",
        infoList: [],
      },
      openList: [
        {
          id: "38594982121131",
          sxf: "22.00",
          name: "amube@zi.nc",
          num: "294.36",
          type: "失败",
        },
        {
          id: "38594982121131",
          sxf: "22.00",
          name: "petvawi@oknu.bd",
          num: "394.36",
          type: "成功",
        },
        {
          id: "38594982121131",
          sxf: "22.00",
          name: "zu@viw.ne",
          num: "924.36",
          type: "成功",
        },
      ],
    };
  },
  created() {
    this.breadList = this.$route.meta.title;
    let id = this.$route.query.id;
    if (id) {
      if (this.$route.query.type == 1) {
        this.$http.get(`/api/orderInfo/getRefundById?id=${id}`).then((res) => {
          if (res.code === "0000") {
            this.info = res.data;
            console.log(this.info)
          }
        });
      } else {
        this.$http
          .get(`/api/orderInfo/listOrderByRefundBatchId?batchId=${id}`)
          .then((res) => {
            if (res.code === "0000") {
              this.info = res.data;
              console.log(this.info);
            } //console.log
          });
      }
    }
  },
  methods: {
    setRefundStatus(val) {
      let str = "";
      let color = "";
      switch (val) {
        case "part_refund":
          str = "部分成功";
          color = "succeed";
          break;
        case "wait_refund":
          str = "处理中";
          color = "pedding";
          break;
        case "success_refund":
          str = "成功";
          color = "succeed";
          break;
        case "fail_refund":
          str = "失败";
          color = "failed";
          break;
      }
      return {
        str,
        color,
      };
    },
    backFn() {
      this.$backTo(`/deal/refundTool`);
    },
    copyAppId(value) {
      const input = document.createElement("input"); // 创建input对象
      input.value = value; // 设置复制内容
      document.body.appendChild(input); // 添加临时实例
      input.select(); // 选择实例内容
      document.execCommand("Copy"); // 执行复制
      document.body.removeChild(input); // 删除临时实例
      this.$message.success("复制成功！");
    },
  },
};
</script>

<style scoped lang="scss">
.content {
  min-height: 780px;
  padding: 160px 100px;
  display: flex;
  justify-content: start;
  flex-wrap: wrap;
  .info {
    width: 33.3%;
    min-width: 500px;
    margin-bottom: 40px;
    padding: 0 2%;
    .title {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #1d1c1c;
      padding-bottom: 15px;
      border-bottom: 1px solid #03bfc6;
    }
    .list {
      margin-top: 35px;
      .item {
        display: flex;
        .tit {
          min-width: 100px;
          margin-right: 32px;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #869daa;
          line-height: 40px;
          text-align: right;
        }
        .desc {
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #1d1c1c;
          line-height: 40px;
          overflow: hidden;
          word-wrap: break-word;
        }
      }
      .openBox {
        margin-bottom: 20px;
        height: 22px;
        font-size: 15px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 600;
        color: #1d1c1c;
        line-height: 22px;
        display: flex;
        justify-content: start;
        td {
          display: inline-block;
          min-width: 16%;
          padding: 0 40px 0 0;
        }
      }
      .openBox1 {
        margin-bottom: 20px;
        height: 22px;
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 400;
        color: #1d1c1c;
        line-height: 22px;
        display: flex;
        justify-content: start;
        text-align: left;
        td {
          min-width: 16%;
          width: 1px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          padding: 0 40px 0 0;
        }
      }
    }
  }
}
.back {
  position: absolute;
  right: 55px;
  top: 20px;
  font-size: 20px;
  cursor: pointer;
}
.left {
  position: absolute;
  left: 55px;
  top: 31px;
  height: 20px;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #869daa;
  line-height: 20px;
}
// :deep(.el-table__expand-icon) {
//   // position: absolute;
//   // left:140px;
//   float: left;
// }
@media screen and (max-width: 1770px) {
  .content {
    .info {
      box-sizing: content-box !important;
      width: 33.3%;
      min-width: 520px;
      margin-bottom: 40px;
      padding: 0 5.5%;
    }
  }
}

@media screen and (max-width: 1550px) {
  .content {
    .info {
      box-sizing: content-box !important;
      width: 33.3%;
      min-width: 488px;
      margin-bottom: 40px;
      padding: 0 2%;
    }
  }
}
</style>
